<template>
  <div id="allmap"></div>
</template>
<script>
export default {
      props: {
    center: {
      type: Object,
      default: () => ({ lng: 120.61456524669649, lat: 31.345347435103882 }),
    },
    zoom: {
      type: Number,
      default: 12,
    },
    markerList:{
            type: Array,
      default: () => [],
    }
  },
    // props:[],
    // 页面加载
    created(){


    },
    // 页面加载完成
    mounted(){
     var points = [];
    for (let index = 0; index < 1; index++) {
       points.push(new BMapGL.Point(120.738463,31.249992))
       points.push(new BMapGL.Point(120.726311,31.25322))
       points.push(new BMapGL.Point(120.664436,31.288584))

       
    }
    //     var points =this.markerList.map(x=>{
    //   return   new BMapGL.Point(x.longitude,x.latitude)
    // })
    //地图初始化
    var bm = new BMapGL.Map("allmap");
    bm.centerAndZoom(new BMapGL.Point(this.center.lng,this.center.lat), 16);

    //坐标转换完之后的回调函数
   let translateCallback = function (data){
      if(data.status === 0) {
        for (var i = 0; i < data.points.length; i++) {
            bm.addOverlay(new BMapGL.Marker(data.points[i]));
            bm.setCenter(data.points[i]);
        }
      }
    }
    setTimeout(function(){
        var convertor = new BMapGL.Convertor();
        convertor.translate(points, COORDINATES_WGS84, COORDINATES_BD09, translateCallback)
    }, 1000);
    },
    //实例销毁之前
      beforeDestroy(){
  },
    //实例销毁后
         destroyed(){
            },
    data(){
        return{
    
        }
    },
    // 方法
    methods:{
    
    },
    // 监听属性
    watch:{
    
    },
    // 组件
    components:{
    
    },
    // 计算属性
    computed: {
        
    },

}
</script>

<style lang="scss" scoped>

#allmap {width: 100%;height: 100%;
}
</style>